﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Interactivity.InteractionRequest;

namespace Hopscotch.Presentation.Controls.Views
{
    /// <summary>
    /// Interaction logic for NotificationView.xaml
    /// </summary>
    public partial class NotificationView : UserControl, IInteractionRequestAware
    {
        public NotificationView()
        {
            this.CloseNotificationCommand = new DelegateCommand(CloseNotification);

            InitializeComponent();
        }

        // Both the FinishInteraction and Notification properties will be set by the 
        // PopupWindowAction/OverlayWindowAction trigger actions
        public Action FinishInteraction { get; set; }

        public ICommand CloseNotificationCommand { get; private set; }

        //DependencyProperty(s)
        public static readonly DependencyProperty NotificationProperty
            = DependencyProperty.Register(nameof(Notification), typeof(INotification), typeof(NotificationView));

        public INotification Notification
        {
            get { return (INotification)this.GetValue(NotificationProperty); }
            set { this.SetValue(NotificationProperty, value); }
        }

        private void CloseNotification()
        {
            if (this.FinishInteraction != null)
                this.FinishInteraction();
        }
    }
}
